// 2025/09/08
// Author: Forever
#include <bits/stdc++.h>
using namespace std;

int n, l, a, b, can[1005];

class SegmentTree {
private:
    struct node {
        int lazy, m;
    } tree[4005];
    int N;

public:
    void build(int p, int l, int r)
    {
        tree[p].m = INT_MAX;
        tree[p].lazy = INT_MAX;
        if (l == r)
            return;
        int mid = (l + r) >> 1;
        build(p << 1, l, mid);
        build(p << 1 | 1, mid + 1, r);
    }
    void pushdown(int p, int l, int r)
    {
        if (tree[p].lazy != INT_MAX) {
            int tag = tree[p].lazy;
            tree[p << 1].lazy = min(tree[p << 1].lazy, tag);
            tree[p << 1 | 1].lazy = min(tree[p << 1 | 1].lazy, tag);
            tree[p << 1].m = min(tree[p << 1].m, tag);
            tree[p << 1 | 1].m = min(tree[p << 1 | 1].m, tag);
            tree[p].lazy = INT_MAX;
        }
    }

    void update(int p, int l, int r, int ql, int qr, int val)
    {
        if (ql <= l && r <= qr) {
            tree[p].lazy = min(tree[p].lazy, val);
            tree[p].m = min(tree[p].m, val);
            return;
        }
        pushdown(p, l, r);
        int mid = (l + r) >> 1;
        if (ql <= mid)
            update(p << 1, l, mid, ql, qr, val);
        if (qr > mid)
            update(p << 1 | 1, mid + 1, r, ql, qr, val);
    }

    int query(int p, int l, int r, int ql, int qr)
    {
        if (ql <= l && r <= qr)
            return tree[p].m;
        pushdown(p, l, r);
        int mid = (l + r) >> 1;
        int res = INT_MAX;
        if (ql <= mid)
            res = min(res, query(p << 1, l, mid, ql, qr));
        if (qr > mid)
            res = min(res, query(p << 1 | 1, mid + 1, r, ql, qr));
        return res;
    }

public:
    SegmentTree(int n)
    {
        N = n;
        build(1, 1, N);
    }
    int query(int ql, int qr)
    {
        return query(1, 1, N, ql, qr);
    }
    void update(int ql, int qr, int val)
    {
        update(1, 1, N, ql, qr, val);
    }
};

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> l >> a >> b;
    l++;
    for (int i = 1; i <= n; i++) {
        int x, y;
        cin >> x >> y;
        x++, y++;
        can[x + 1]--, can[y]++;
    }
    for (int i = 1; i <= l; i++)
        can[i] += can[i - 1];
    SegmentTree dp(l);
    dp.update(1, 1, 0);
    for (int i = 1; i <= l - a * 2; i += 2) {
        if (can[i] != 0 || dp.query(i, i) == INT_MAX)
            continue;
        int x = i + a * 2, y = min(l, i + b * 2);
        dp.update(x, y, dp.query(i, i) + 1);
    }
    int ans = dp.query(l, l);
    cout << (ans == INT_MAX ? -1 : ans) << endl;
    return 0;
}